package 字母搜集;

import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    static int N = 510;
    static char[][] g = new char[N][N];
    static int[][] f = new int[N][N];

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int m = in.nextInt();
        for (int i = 0; i < n; i++) {
            g[i] = in.next().toCharArray();
        }
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                f[i][j] = Math.max(f[i - 1][j], f[i][j - 1]) + get(g[i - 1][j - 1]);
            }
        }
        System.out.println(f[n][m]);
    }

    private static int get(char ch) {
        if (ch == 'l') {
            return 4;
        } else if (ch == 'o') {
            return 3;
        } else if (ch == 'v') {
            return 2;
        } else if (ch == 'e') {
            return 1;
        }
        return 0;
    }
}
